from geopy.distance import geodesic


def get_distance_by_location(_location1: tuple, _location2: tuple, unit: str = "m"):
    # if (0 <= int(_location1[0]) <= 90 and 0 <= int(_location2[0]) <= 90) and (
    #         0 <= int(_location1[1]) <= 180 and 0 <= int(_location2[1]) <= 180):
    if unit == "m":
        return geodesic(_location1, _location2).m
    else:
        return geodesic(_location1, _location2).km


# else:
#     msg = f"参数是: {_location1}, {_location2}, 有参数不合规, 纬度在前, 经度在后。"
#     raise RuntimeError(msg)


if __name__ == "__main__":
    location1 = (-1, 0)
    location2 = (0, -1)
    get_distance_by_location(location1, location2)
